import numpy as np
from coommon import sigmoid, Identity


#初始化
def init_network():
    network = {}
    # 输入层3个神经元，隐藏层2个神经元，输出层2个神经元
    #第一层参数
    network['W1'] = np.array([[0.1, 0.3, 0.5], [0.2, 0.4, 0.6]])
    network['b1'] = np.array([0.1, 0.2, 0.3])
    #第二层参数
    network['W2'] = np.array([[0.1, 0.4], [0.2, 0.5], [0.3, 0.6]])
    network['b2'] = np.array([0.1, 0.2])
    #第三层参数
    network['W3'] = np.array([[0.1, 0.3], [0.2, 0.4]])
    network['b3'] = np.array([0.1, 0.2])
    return network

 #前向传播
def forward(network, x):
    W1, W2, W3 = network['W1'], network['W2'], network['W3']
    b1, b2, b3 = network['b1'], network['b2'], network['b3']
    #第一层
    a1 = np.dot(x, W1) + b1
    print(a1)
    z1 = sigmoid(a1)
    #第二层
    a2 = np.dot(z1, W2) + b2
    z2 = sigmoid(a2)
    #第三层
    a3 = np.dot(z2, W3) + b3
    y = Identity(a3)

    return y
#测试

network = init_network()
x = np.array([1.0, 0.5])
y = forward(network, x)
print(y)
